package com.authine.cloudpivot.app.openapi.util;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * openAPI的签名工具类
 *
 * @author lifuchun
 */
public final class OpenApiUtils {

    private OpenApiUtils() {
    }

    public static boolean checkSignNoDependency(String userId, String nonce, String sign, String appKey, String appSecret) {
        return signNoDependency(userId, nonce, appKey, appSecret).equalsIgnoreCase(sign);
    }

    public static String signNoDependency(String userId, String nonce, String appKey, String appSecret) {
        return DigestUtils.md5Hex(appKey.concat(userId).concat(nonce).concat(appSecret)).toLowerCase();
    }


}
